#include <iostream>
#include "TCPSocket.h"
#include "NetAddr.h"
#include "Exception.h"
#include "TimeVal.h"
#include "TCPServer.h"
#include "LogManager.h"
#include "SocketHandle.h"

int main(int argc, char** argv)
{

	LogManager::Instance()->UseAdapter(LogManager::STDOUT_ADAPTER_TYPE);
	LogManager::Instance()->LogLevel(LogManager::TRACE);
	try
	{

		NetAddr addr(NetAddr::_AF_INET, 6782, "10.8.32.172");
		TCPServer server(addr);

		SocketHandle hdl;
		server.RegisterHandler(&hdl, Socket::_READ_EVENT);
		TimeVal val;
		server.HandleEvents(val);

		LOGTRACE("after server.HandleEvents");

	}
	catch(Exception& e)
	{
		std::cout << e.What() << std::endl;
	}
	catch(...)
	{
		LOGTRACE("---unknown exception");
	}

	return 0;
}	
